package com.JZ.QM.service.impl;

import com.JZ.QM.common.dao.TradeDetailDao;
import com.JZ.QM.common.dao.TradeRecordDao;
import com.JZ.QM.common.entity.TradeLDetailEntity;
import com.JZ.QM.common.entity.TradeRecordEntity;
import com.JZ.QM.common.utils.PageUtils;
import com.JZ.QM.common.utils.Query;
import com.JZ.QM.service.TradeRecordService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

/**
 * @author: cyc
 * @email cyc@gmail.com
 * @date: 2020/7/2 21:00
 */
@Slf4j
@Service()
public class TradeRecordServiceImpl extends ServiceImpl<TradeRecordDao, TradeRecordEntity> implements TradeRecordService {
    @Resource
    TradeDetailDao tradeDetailDao;

    @Override
    public PageUtils queryPage(Map<String, Object> params) throws Exception {
        IPage<TradeRecordEntity> page = this.page(
                new Query<TradeRecordEntity>().getPage(params),
                new QueryWrapper<TradeRecordEntity>()
        );
        return new PageUtils(page);
    }

    /**
     * 获取交易记录及其详细信息
     * @param tradeId 交易记录id
     * @param userId 用户id
     * @return
     */
    @Override
    public ArrayList<TradeLDetailEntity> getTradeRecords(Long tradeId,Long userId) {
        //交易记录列表
        ArrayList<TradeLDetailEntity> tradeLists=new ArrayList<>();
        //获取交易记录
        tradeLists=tradeDetailDao.getTradeAccountDetailLists(tradeId,userId);
        System.out.println("交易记录为"+tradeLists);
        return tradeLists;
    }

    /**
     * 获取银行的交易记录及其详细信息
     * @param tradeId 交易记录id
     * @param userId 用户id
     * @return
     */
    @Override
    public ArrayList<TradeLDetailEntity> getTradeRecordsOfBank(Long tradeId, Long userId) {
        //交易记录列表
        ArrayList<TradeLDetailEntity> tradeLists=new ArrayList<>();
        //获取银行转账交易记录
        tradeLists=tradeDetailDao.getTradeAccountDetailListOfBank(tradeId,userId);
        System.out.println("银行交易记录为"+tradeLists);
        return tradeLists;
    }

}